<meta charset="UTF-8">

<?php

include_once("../functions/db_manipulate.php");
if (!init()) {
    redirect('?action=login');
}

connectDB();
startTransaction();

$resultSet = mysql_query("INSERT INTO entergroup(userid, groupid)
                          VALUES ('" . mysql_real_escape_string($_SESSION['id']) . "','" . mysql_real_escape_string($_GET['gid']) . "')");

$initiatorAction = \controller\ControllerUtil::getEncodedActionFromUrlWithParameters($_SERVER['HTTP_REFERER']);

if ($resultSet) {
    commitTransaction();
  redirect("?action=msg&header=header.group.enter.success&body=body.group.enter.success&view=" . $initiatorAction);
} else {
  rollbackTransaction();
  redirect("?action=msg&header=header.group.enter.failed&body=body.group.enter.failed&view=" . $initiatorAction);
}

?>
